﻿Imports System
Imports System.IO
Imports System.Net
Public Class frmProfileConfiguration
    Public sTemp As String
    Public TwoPieceCount As Integer
    Private Sub frmProfileConfiguration_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        e.Cancel = True
        Me.Hide()
    End Sub
    Private Sub btnLoadCharArmory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadArmory.Click
        Dim sLog As String = My.Application.Info.DirectoryPath & "\armorydownload.txt"
        If File.Exists(sLog) Then File.Delete(sLog)
        My.Computer.Network.DownloadFile("", sLog)

        Dim oRead As New StreamReader(sLog)
        Dim oWrite As New StreamWriter(My.Application.Info.DirectoryPath & "\armoryoutput.txt")
        Dim a As Integer = 0
        While oRead.Peek <> -1
            a += 1
            oWrite.WriteLine(a & " " & oRead.ReadLine)
            oWrite.WriteLine()
        End While
        oRead.Close()
        oWrite.Close()
        File.Delete(sLog)
    End Sub
    Private Sub cbCookieCutter_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCookieCutter.CheckedChanged
        If cbCookieCutter.Checked Then
            cbCustomSpec.Checked = False
            txtCustomSpec.Enabled = False
            txtCustomSpec.Visible = False
            txtCustomSpecDescription.Enabled = False
            txtCustomSpecDescription.Visible = False
            comboCookieCutter.Enabled = True
            comboCookieCutter.Visible = True
            sTemp = CStr(comboCookieCutter.SelectedItem)
            comboCookieCutter.SelectedItem = Nothing
            comboCookieCutter.SelectedItem = CObj(sTemp)
        Else
            cbCustomSpec.Checked = True
        End If
    End Sub
    Private Sub cbCustomSpec_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbCustomSpec.CheckedChanged
        If cbCustomSpec.Checked Then
            cbCookieCutter.Checked = False
            txtCustomSpec.Enabled = True
            txtCustomSpec.Visible = True
            txtCustomSpecDescription.Enabled = True
            txtCustomSpecDescription.Visible = True
            comboCookieCutter.Enabled = False
            comboCookieCutter.Visible = False
        Else
            cbCookieCutter.Checked = True
        End If
    End Sub
    Private Sub comboCookieCutter_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboCookieCutter.SelectedIndexChanged
        Select Case comboCookieCutter.Text
            Case "Arcane (0/3 SotM)", "Arcane (1/3 SotM)", "Arcane (3/3 SotM)", "Arcane (Master of Elements)", "Arcane (Scorch)"
                comboGlyph1.SelectedItem = "Arcane Blast"
                comboGlyph2.SelectedItem = "Arcane Missiles"
                comboGlyph3.SelectedItem = "Molten Armor"
                comboArcaneRotation.SelectedItem = "4xAB->MBAM (fishes)"
            Case "TtW Fireball (1/3 SotM)", "TtW Fireball (3/3 SotM)"
                comboGlyph1.SelectedItem = "Fireball"
                comboGlyph2.SelectedItem = "Living Bomb"
                comboGlyph3.SelectedItem = "Molten Armor"
            Case "Frostfire (deep fire)"
                comboGlyph1.SelectedItem = "Frostfire"
                comboGlyph2.SelectedItem = "Living Bomb"
                comboGlyph3.SelectedItem = "Molten Armor"
            Case "Frostfire (deep frost)"
                comboGlyph1.SelectedItem = "Frostfire"
                comboGlyph2.SelectedItem = "Eternal Water"
                comboGlyph3.SelectedItem = "Molten Armor"
            Case "Raid Frost"
                comboGlyph1.SelectedItem = "Frostbolt"
                comboGlyph2.SelectedItem = "Eternal Water"
                comboGlyph3.SelectedItem = "Molten Armor"
            Case "Scorch Build"
                comboGlyph1.SelectedItem = "Scorch"
                comboGlyph2.SelectedItem = "Living Bomb"
                comboGlyph3.SelectedItem = "Molten Armor"
        End Select
    End Sub
    Private Sub comboGlyph1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboGlyph1.SelectedIndexChanged
        If comboGlyph1.SelectedItem Is comboGlyph2.SelectedItem Then comboGlyph2.SelectedItem = "None"
        If comboGlyph1.SelectedItem Is comboGlyph3.SelectedItem Then comboGlyph3.SelectedItem = "None"
    End Sub
    Private Sub comboGlyph2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboGlyph2.SelectedIndexChanged
        If comboGlyph2.SelectedItem Is comboGlyph1.SelectedItem Then comboGlyph1.SelectedItem = "None"
        If comboGlyph2.SelectedItem Is comboGlyph3.SelectedItem Then comboGlyph3.SelectedItem = "None"
    End Sub
    Private Sub comboGlyph3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboGlyph3.SelectedIndexChanged
        If comboGlyph3.SelectedItem Is comboGlyph1.SelectedItem Then comboGlyph1.SelectedItem = "None"
        If comboGlyph3.SelectedItem Is comboGlyph2.SelectedItem Then comboGlyph2.SelectedItem = "None"
    End Sub
    Private Sub cbT72Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT72Piece.CheckedChanged
        If cbT72Piece.Checked Then
            If TwoPieceCount > 0 Then cbT84Piece.Checked = False : cbT94Piece.Checked = False : cbT104Piece.Checked = False
            If TwoPieceCount > 1 Then cbT82Piece.Checked = False : cbT92Piece.Checked = False : cbT102Piece.Checked = False
            TwoPieceCount += 1
        Else
            cbT74Piece.Checked = False
            TwoPieceCount -= 1
        End If
    End Sub
    Private Sub cbT74Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT74Piece.CheckedChanged
        If cbT74Piece.Checked Then cbT72Piece.Checked = True : If TwoPieceCount > 1 Then cbT82Piece.Checked = False : cbT92Piece.Checked = False : cbT102Piece.Checked = False
    End Sub
    Private Sub cbT82Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT82Piece.CheckedChanged
        If cbT82Piece.Checked Then
            If TwoPieceCount > 0 Then cbT74Piece.Checked = False : cbT94Piece.Checked = False : cbT104Piece.Checked = False
            If TwoPieceCount > 1 Then cbT72Piece.Checked = False : cbT92Piece.Checked = False : cbT102Piece.Checked = False
            TwoPieceCount += 1
        Else
            cbT84Piece.Checked = False
            TwoPieceCount -= 1
        End If
    End Sub
    Private Sub cbT84Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT84Piece.CheckedChanged
        If cbT84Piece.Checked Then cbT82Piece.Checked = True : If TwoPieceCount > 1 Then cbT72Piece.Checked = False : cbT92Piece.Checked = False : cbT102Piece.Checked = False
    End Sub
    Private Sub cbT92Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT92Piece.CheckedChanged
        If cbT92Piece.Checked Then
            If TwoPieceCount > 0 Then cbT84Piece.Checked = False : cbT74Piece.Checked = False : cbT104Piece.Checked = False
            If TwoPieceCount > 1 Then cbT82Piece.Checked = False : cbT72Piece.Checked = False : cbT102Piece.Checked = False
            TwoPieceCount += 1
        Else
            cbT94Piece.Checked = False
            TwoPieceCount -= 1
        End If
    End Sub
    Private Sub cbT94Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT94Piece.CheckedChanged
        If cbT94Piece.Checked Then cbT92Piece.Checked = True : If TwoPieceCount > 1 Then cbT82Piece.Checked = False : cbT72Piece.Checked = False : cbT102Piece.Checked = False
    End Sub
    Private Sub cbT102Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT102Piece.CheckedChanged
        If cbT102Piece.Checked Then
            If TwoPieceCount > 0 Then cbT84Piece.Checked = False : cbT94Piece.Checked = False : cbT74Piece.Checked = False
            If TwoPieceCount > 1 Then cbT82Piece.Checked = False : cbT92Piece.Checked = False : cbT72Piece.Checked = False
            TwoPieceCount += 1
        Else
            cbT104Piece.Checked = False
            TwoPieceCount -= 1
        End If
    End Sub
    Private Sub cbT104Piece_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbT104Piece.CheckedChanged
        If cbT104Piece.Checked Then cbT102Piece.Checked = True : If TwoPieceCount > 1 Then cbT82Piece.Checked = False : cbT92Piece.Checked = False : cbT72Piece.Checked = False
    End Sub
    Private Sub lblTalentCalculator_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lblTalentCalculator.LinkClicked
        Diagnostics.Process.Start("http://www.wowarmory.com/talent-calc.xml?c=Mage")
    End Sub
    Private Sub comboTrinket1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboTrinket1.SelectedIndexChanged
        If comboTrinket1.SelectedItem Is comboTrinket2.SelectedItem And comboTrinket1.SelectedItem IsNot "None" Then
            comboTrinket2.SelectedItem = "None"
        ElseIf (comboTrinket1.SelectedItem Is "Muradin's Spyglass" Or comboTrinket1.SelectedItem Is "Muradin's Spyglass (Heroic)") And (comboTrinket2.SelectedItem Is "Muradin's Spyglass" Or comboTrinket2.SelectedItem Is "Muradin's Spyglass (Heroic)") Then
            comboTrinket2.SelectedItem = "None"
        ElseIf (comboTrinket1.SelectedItem Is "Dislodged Foreign Object" Or comboTrinket1.SelectedItem Is "Dislodged Foreign Object (Heroic)") And (comboTrinket2.SelectedItem Is "Dislodged Foreign Object" Or comboTrinket2.SelectedItem Is "Dislodged Foreign Object (Heroic)") Then
            comboTrinket2.SelectedItem = "None"
        ElseIf (comboTrinket1.SelectedItem Is "Sliver of Pure Ice" Or comboTrinket1.SelectedItem Is "Sliver of Pure Ice (Heroic)") And (comboTrinket2.SelectedItem Is "Sliver of Pure Ice" Or comboTrinket2.SelectedItem Is "Sliver of Pure Ice (Heroic)") Then
            comboTrinket2.SelectedItem = "None"
        ElseIf (comboTrinket1.SelectedItem Is "Phylactery of the Nameless Lich" Or comboTrinket1.SelectedItem Is "Phylactery of the Nameless Lich (Heroic)") And (comboTrinket2.SelectedItem Is "Phylactery of the Nameless Lich" Or comboTrinket2.SelectedItem Is "Phylactery of the Nameless Lich (Heroic)") Then
            comboTrinket2.SelectedItem = "None"
        End If
    End Sub
    Private Sub comboTrinket2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboTrinket2.SelectedIndexChanged
        If comboTrinket2.SelectedItem Is comboTrinket1.SelectedItem And comboTrinket2.SelectedItem IsNot "None" Then
            comboTrinket1.SelectedItem = "None"
        ElseIf (comboTrinket2.SelectedItem Is "Muradin's Spyglass" Or comboTrinket2.SelectedItem Is "Muradin's Spyglass (Heroic)") And (comboTrinket1.SelectedItem Is "Muradin's Spyglass" Or comboTrinket1.SelectedItem Is "Muradin's Spyglass (Heroic)") Then
            comboTrinket1.SelectedItem = "None"
        ElseIf (comboTrinket2.SelectedItem Is "Dislodged Foreign Object" Or comboTrinket2.SelectedItem Is "Dislodged Foreign Object (Heroic)") And (comboTrinket1.SelectedItem Is "Dislodged Foreign Object" Or comboTrinket1.SelectedItem Is "Dislodged Foreign Object (Heroic)") Then
            comboTrinket1.SelectedItem = "None"
        ElseIf (comboTrinket2.SelectedItem Is "Sliver of Pure Ice" Or comboTrinket2.SelectedItem Is "Sliver of Pure Ice (Heroic)") And (comboTrinket1.SelectedItem Is "Sliver of Pure Ice" Or comboTrinket1.SelectedItem Is "Sliver of Pure Ice (Heroic)") Then
            comboTrinket1.SelectedItem = "None"
        ElseIf (comboTrinket2.SelectedItem Is "Phylactery of the Nameless Lich" Or comboTrinket2.SelectedItem Is "Phylactery of the Nameless Lich (Heroic)") And (comboTrinket1.SelectedItem Is "Phylactery of the Nameless Lich" Or comboTrinket1.SelectedItem Is "Phylactery of the Nameless Lich (Heroic)") Then
            comboTrinket1.SelectedItem = "None"
        End If
    End Sub
    Private Sub cbLightweave_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbLightweave.CheckedChanged
        If cbLightweave.Checked Then cbDarkglow.Checked = False
    End Sub
    Private Sub cbDarkglow_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbDarkglow.CheckedChanged
        If cbDarkglow.Checked Then cbLightweave.Checked = False
    End Sub
End Class